﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SmallERP.Bll.PinBan;
using SmallERP.MODEL.FoundationModel;
using SmallERP.MODEL.FenPian;
using Smallerp.Contracts.DataContracts;
using Smallerp.Contracts;

namespace SmallERP.PinBan.ImportPhoto.Forms
{
    public partial class FrmModifyPara : Form
    {
        public FrmModifyPara(OrderViewDCT inView,IOperateDB inOperateDB)
        {
            InitializeComponent();
            _view = inView;
            _operateDB = inOperateDB;
        }
        IOperateDB _operateDB;
        OrderViewDCT _view = new OrderViewDCT();
        private void FrmModifyPara_Load(object sender, EventArgs e)
        {
            Init();
        }
        void Init()
        {
            labelViewName.Text = _view.OrderName;
            comboBoxFace.DisplayMember = "PaperFaceName";
            comboBoxFace.ValueMember = "PaperFaceId";
            List<PaperFaceDCT> listFace = _operateDB.GetAllPaperFace();
          //  listFace.Add(new PaperFaceDCT() { PaperFaceId = 0, PaperFaceName = "无" });
            comboBoxFace.DataSource = listFace;
            if (listFace.Count > 0)
            {
                //comboBoxFace.SelectedIndex = 0;
                comboBoxFace.SelectedItem = _view.PaperFace;
                comboBoxFace.Text = _view.PaperFace.PaperFaceName;
                // PaperFaceInfo = ((PaperFaceDCT)comboBoxFace.SelectedItem);
            }
            comboBoxType.DisplayMember = "PaperTypeName";
            comboBoxType.ValueMember = "PaperTypeId";
            List<PaperTypeDCT> listType = _operateDB.GetAllPaperType();
          //  listType.Add(new PaperTypeDCT() { PaperTypeId = 0, PaperTypeName = "无" });
            comboBoxType.DataSource = listType;
            if (listType.Count > 0)
            {
                comboBoxType.SelectedItem = _view.PaperTypeInfo;
                comboBoxType.Text = _view.PaperTypeInfo.PaperTypeName;

                // PaperTypeInfo = ((PaperTypeDCT)comboBoxType.SelectedItem);
            }


            comboBoxPrint.DisplayMember = "PName";
            comboBoxPrint.ValueMember = "PrinterID";
            List<PrinterDCT> printList = _operateDB.GetAllPrinters();
        //    printList.Add(new PrinterDCT() { PrinterID = 0, PName = "无" });
            comboBoxPrint.DataSource = printList;
            if (printList.Count > 0)
            {
                comboBoxPrint.SelectedItem = _view.PrintInfo;
                comboBoxPrint.Text = _view.PrintInfo.PName;
                // PrinterInfo = ((PrinterDCT)comboBoxPrint.SelectedItem);
            }
            comboBoxPriority.SelectedText = _view.Priority.ToString();
            numericUpDownNum.Text = _view.ProductNum.ToString();

        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            _view.PaperFace = (PaperFaceDCT)comboBoxFace.SelectedItem;
            _view.PaperTypeInfo = (PaperTypeDCT)comboBoxType.SelectedItem;
            _view.PrintInfo = (PrinterDCT)comboBoxPrint.SelectedItem;
            _view.ProductNum = Convert.ToInt32(numericUpDownNum.Text);
            _view.Priority = Convert.ToInt32(comboBoxPriority.Text);
            //_view.Priority=
            this.Close();
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

    }
}
